package com.icode.core.shared;

import com.icode.core.model.manage.Investigate;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * User: xianfei
 * Date: 15-3-18
 * Time: 上午11:04
 * To change this template use File | Settings | File Templates.
 */
public class LuckHandle {

    private List<Investigate> investigates = new ArrayList<>();
    private static LuckHandle luckHandle = new LuckHandle();


    public static String selectLuckPerson() {
        try {
            Random random = new Random();
            int index = random.nextInt(luckHandle.investigates.size());
            Investigate investigate = luckHandle.investigates.get(index);
            luckHandle.investigates.remove(index);
            return investigate.name() + "&" + investigate.phoneNum();
        } catch (Exception e) {
            return "error";
        }
    }

    public static void initInvestigates(List<Investigate> investigates) {
        luckHandle.investigates = investigates;
    }

}
